package itdep.jsf.tag;

import com.sun.facelets.FaceletContext;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagConfig;
import com.sun.facelets.tag.TagHandler;
import itdep.jsf.internal.DelegateConverter;

import javax.el.ELException;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
import javax.faces.convert.Converter;
import java.io.IOException;

/**
 * todo: delete this
 * <p/>
 * Created: 24.04.2009 17:16:25 by Tolar
 */
@Deprecated
public class ConverterTag extends TagHandler {
	private final TagAttribute value;

	public ConverterTag(TagConfig config) {
		super(config);
		value = getRequiredAttribute("value");
	}

	public void apply(FaceletContext ctx, final UIComponent parent) throws IOException, FacesException, ELException {
		final Converter c = new DelegateConverter(value.getValueExpression(ctx, Converter.class));
		((ValueHolder) parent).setConverter(c);
	}

}
